<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			/********************
			1.请为网吧做一套系统，用于凭借身份证号码检测一个人是否成年，成年则欢迎，不成年则请出。
			提示：new Date();获取时间
				 string.sub();截取字符串
			********************/
			function person (number) {
				this.number = number;
				this.getNumber = function () {
					return number;
				};
				this.isAdult = function () {
					var num = number.slice(6,10);
					var d = new Date();
					if ( d.getFullYear() - num >= 18 ){
						return true;
					} else {
						return false;
					}
				}
			}

			var Nicolas = new person('552233112901239129');
			console.log(Nicolas.isAdult());
			
			/********************
			2.用至少两种定义对象的方式来定义一辆车，车有对应的属性（例如有尺寸，颜色，马力）和方法（行驶，开车灯）
			（请至少写出8个属性，5种方法）
			********************/
			var car = {
				size : 'middle',
				color : 'skyblue',
				getColor : function (color) {
					return color;
				},
				horsepower : 200,
				use : function (key) {
					return key;
				},
				openLight : function (switch) {
					if (switch == true){
						alert('open the light.');
					} else {
						alert('close the light.');
					}
				},
				whose : function (name) {
					alert( 'this is ' + name + " 's " + 'car' );
				},
				howMuch : function (insurance,gasCost,upkeep) {
					return insurance + gasCost + upkeep;	
				},
				hasInsurance : true
			}
			

			function vehicle (size, color,horsepower, key, switch,name,insurance,gasCost,upkeep ) {
				var v = new Obeject();
				v.size = size;
				v.color = color;
				v.getColor = function (color) {
					return color;
				};
				v.horsepower = horsepower;
				v.use = function (key) {
					return car;
				};
				v.openLight = function (switch) {
					if (switch == true){
						alert('open the light.');
					} else {
						alert('close the light.');
					}
				};
				v.whose = function (name) {
					alert( 'this is ' + name + " 's " + 'car' );
				};
				v.howMuch = function (insurance,gasCost,upkeep) {
					return insurance + gasCost + upkeep;
				};
				v.hasInsurance = true;
			}
			

			var  car  = vehicle('middle','skyblue',200,'key', true, 'Nicolas', 1200,400,300);
		</script>
	</body>
</html>
